package com.ucl.common.enumeration;

public enum ProductEnum {

    PRODUCT_SIM("Product@sim",1),
    PRODUCT_MIFI("Product@mifi",2),
    PRODUCT_OPERATOR("Product@operator",3),
    PRODUCT_OTHER("未知产品",4);


    // 成员变量
    private String name;
    private int index;

    ProductEnum(String name, Integer index) {
        this.name = name;
        this.index = index;
    }

    public static ProductEnum getByName(String name){
        for (ProductEnum constants : values()) {
            if (constants.getName().equalsIgnoreCase(name)) {
                return constants;
            }
        }
        return PRODUCT_OTHER;
    }

    // 只保留Getter方法，set方法（外界可以改变其成员属性），有点违背了枚举设计的初衷
    public String getName() {
        return name;
    }

    public Integer getIndex() {
        return index;
    }
}
